package com.stu.dao.sys.impl;

import java.io.Serializable;
import java.sql.SQLException;
import java.util.Date;
import java.util.UUID;

import org.springframework.stereotype.Repository;

import com.stu.dao.base.impl.BaseDao;
import com.stu.dao.sys.ISysLogDao;
import com.stu.entity.permission.PermissionUser;
import com.stu.entity.sys.SysLog;

@Repository
public class SysLogDao extends BaseDao<SysLog> implements ISysLogDao{

	@Override
	public Serializable saveLog(String logType,String logLevel,String logContent,String logParam) {
		SysLog log=new SysLog(logType, logLevel, logContent, logParam);
		log.setUuid(UUID.randomUUID().toString().replaceAll("-", ""));
		log.setCreateTime(new Date());
		try {
			return super.save(log);
		} catch (SQLException e) {
			return 0;
		}
	}

	@Override
	public Serializable saveLog(String logType,String logLevel,String logContent,String logParam,
			PermissionUser currentPermissionUser) {
		SysLog log=new SysLog(logType, logLevel, logContent, logParam,new PermissionUser());
		log.setUuid(UUID.randomUUID().toString().replaceAll("-", ""));
		log.setCreateTime(new Date());
		try {
			return super.save(log);
		} catch (SQLException e) {
			return 0;
		}
	}

}
